package server.layer;

import java.io.IOException;
import java.sql.*;

/**
 * Created by IntelliJ IDEA.
 * User: Awake
 * Date: 22.04.12
 * Time: 18:53
 * To change this template use File | Settings | File Templates.
 */
public class JDBCUtil {

    private static Statement stat;
    private static Connection conn;

    public static Connection getConn() {
        return conn;
    }

    public static Statement getStat() {
        return stat;
    }

    public static void startConnection() throws SQLException, IOException {
        conn = null;
        String url = "jdbc:mysql://localhost:3306/";
        String dbName = "test_base";
        String driver = "com.mysql.jdbc.Driver";
        String username = "root";
        String password = "shmalipakovan";

        try {
            if (driver != null) System.setProperty("jdbc.drivers", driver);
            conn = DriverManager.getConnection(url + dbName, username, password);
            stat = conn.createStatement();

        } catch (SQLException e) {
            e.printStackTrace();
            conn.close();
        }
    }

    public static void updatePerson(Person p)throws SQLException, IOException{
        PreparedStatement updateFirstName;
        PreparedStatement updateLastName;
        String updFirstName = "";


    }


}
